package lab02.test13;

/**
 * Created by 婷婷 on 2017/10/20.
 */
public class Gymnastics extends ComputerAverage{
    @Override
    double average(double[] scores) {
        double max;
        double min;
        double sum = 0;
        double gymnasticsAverageScores;
        max = min = scores [0];

        //用for循环找出分数中的最高分和最低分
        for (int i = 0;i<scores.length;i++){
            if (scores[i]>max){
                max = scores[i];
            }else if (scores[i]<min){
                min = scores[i];

            }
        }

        //求出总分
        for (int i = 0;i<scores.length;i++){
            sum  += scores[i];
        }
        //总分减去最高分和最低分
            sum = sum-max-min;

        gymnasticsAverageScores = sum/(scores.length-2);
        return gymnasticsAverageScores;
    }
}
